#include <stdio.h>
#include <stdio.h>
int main()
{
    int n;
    scanf_s("%d", &n);
    int a[1001], i = 0, c;
    while (n != 1)
    {
        a[i] = n;
        i++;
        if (n % 2 == 0)
            n = n / 2;
        else
            n = n * 3 + 1;
    }
    a[i] = 1;
    for (c = i; c >= 0; c--)
    {
        printf("%d ", a[c]);
    }
    return 0;
}
	